x86 dom builder: Allocate domU pages in batches.
authorKeir Fraser <keir.fraser@citrix.com>
Thu, 19 Mar 2009 10:04:15 +0000 (10:04 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Thu, 19 Mar 2009 10:04:15 +0000 (10:04 +0000)
Allows a 32-bit dom0 to create very large guests.

Signed-off-by: Mukesh Rathor <mukesh.rathor@oracle.com>
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
tools/libxc/xc_dom_x86.c

index 9306636ba8c7bc6294e5a75e4d7b662c703c0ad2..6ae9487656d9d9732f756ac0a6dd683ddee86b0c 100644 (file)
@@ -694,7 +694,7 @@ static int x86_shadow(int xc, domid_t domid)
 int arch_setup_meminit(struct xc_dom_image *dom)
 {
     int rc;
-    xen_pfn_t pfn;
+    xen_pfn_t pfn, allocsz, i;
 
     rc = x86_compat(dom->guest_xc, dom->guest_domid, dom->guest_type);
     if ( rc )
@@ -713,9 +713,15 @@ int arch_setup_meminit(struct xc_dom_image *dom)
         dom->p2m_host[pfn] = pfn;
 
     /* allocate guest memory */
-    rc = xc_domain_memory_populate_physmap(dom->guest_xc, dom->guest_domid,
-                                           dom->total_pages, 0, 0,
-                                           dom->p2m_host);
+    for ( i = rc = allocsz = 0; (i < dom->total_pages) && !rc; i += allocsz )
+    {
+        allocsz = dom->total_pages - i;
+        if ( allocsz > 1024*1024 )
+            allocsz = 1024*1024;
+        rc = xc_domain_memory_populate_physmap(
+            dom->guest_xc, dom->guest_domid, allocsz, 0, 0, &dom->p2m_host[i]);
+    }
+
     return rc;
 }